package com.pzy.base.configuration;

import com.mybatisflex.core.audit.AuditManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MyBatisFlexConfiguration {
    private static final Logger logger = LoggerFactory
            .getLogger("com.mybatisflex.PrintSql");

    public MyBatisFlexConfiguration() {
        // 开启审计功能
        AuditManager.setAuditEnable(true);

        // 设置 SQL 审计收集器
        AuditManager.setMessageCollector(auditMessage -> logger.debug("{}, 执行用时: {}ms", auditMessage.getFullSql(),
                auditMessage.getElapsedTime()));
    }
}
